FROM {{ namespace }}/{{ image_prefix }}prometheus-base:{{ tag }}
{% block labels %}
LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build_date }}"
{% endblock %}

{% block prometheus_blackbox_exporter_header %}{% endblock %}

{% import "macros.j2" as macros with context %}

{% if base_package_type == 'rpm' %}
    {% set blackbox_packages = [
        'libcap'
    ] %}
{% elif base_package_type == 'deb' %}
    {% set blackbox_packages = [
        'libcap2-bin'
    ] %}
{% endif %}

{{ macros.install_packages(blackbox_packages | customizable("packages")) }}

{% block prometheus_blackbox_exporter_install %}
ADD prometheus-blackbox-exporter-archive /prometheus-blackbox-exporter-source

RUN ln -s /prometheus-blackbox-exporter-source/* prometheus-blackbox-exporter \
    && mkdir -p /opt/blackbox_exporter/ \
    && cp /prometheus-blackbox-exporter/blackbox_exporter /opt/blackbox_exporter/ \
    && setcap cap_net_raw+ep /opt/blackbox_exporter/blackbox_exporter
{% endblock %}

{{ macros.kolla_patch_sources() }}

{% block prometheus_blackbox_exporter_footer %}{% endblock %}
{% block footer %}{% endblock %}

USER prometheus
